(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var n=s.call(t,r||"default");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function r(e,r,s){return(r=t(r))in e?Object.defineProperty(e,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[r]=s,e}const s=e=>void 0!==e;function n(e){return"object"==typeof e&&null!==e}let o=function(e){return e.Init="init",e.Params="params",e.ReachGoal="reachGoal",e.Hit="hit",e}({});class i{static visitParams(e,t,r){i.visitParamsCommon(e,t,{goalParams:r})}static isCounterReady(){return!!window.Ya||!!window.ym}static visitParamsAsync(e,t){return new Promise(((r,s)=>{try{i.visitParamsCommon(e,t,{callback:r})}catch(e){s(e)}}))}static reachGoal(e,t,r){"undefined"!=typeof ym&&(r?ym(e,o.ReachGoal,t,r):ym(e,o.ReachGoal,t))}static hit(e,t,r){ym(e,o.Hit,t,r)}static getCounters(){const e=Ya?._metrika?.getCounters();return Array.isArray(e)?e.map((e=>{if(n(e)&&"number"==typeof e.id){const t=Number(e.type);return{id:e.id,type:isNaN(t)?void 0:t,accurateTrackBounce:!!e.accurateTrackBounce,clickmap:!!e.clickmap,trackHash:!!e.trackHash,trackLinks:!!e.trackLinks,webvisor:!!e.webvisor}}})).filter(s):[]}static getEcomSettings(){const e=window.Ya?._metrika?.ecrs;if(Array.isArray(e))return e}static getCounterIdsWithEcomSettings(){const e=i.getEcomSettings();return e?.map((e=>{const t=e.counterKey.split(":")[0],r=JSON.parse(e.settings);return{counterId:Number(t),settings:{isProduction:1===r.ec,isTesting:1===r.ect,isAIFeatureEnabled:1===r.eaim}}}))}static getZeroCodeConversionMarkup(){let e;const t=window.Ya?._metrika?.ecmv;if(t){e=i.getCounters().reduce(((e,r)=>{const s=t[`${r.id}:0`];return s&&(e[r.id]=JSON.parse(s)),e}),{})}return e}static getClientId(e){return new Promise((t=>{const r=window.Ya?._metrika?.counters?.[`${e}:0`];r?r.getClientID((e=>t(e))):t(void 0)}))}static visitParamsCommon(e,t,r){const{goalParams:n,callback:i}=r||{},a=`yaCounter${e}`,c=a in window?window[a]:window.Ya?._metrika?.counters?.[`${e}:0`];if(window.Ya?.Metrika&&c instanceof window.Ya.Metrika||!window.ym&&window.Ya?.Metrika2&&c instanceof window.Ya.Metrika2)return void(i?c.params(t,i):c.params(t));if(!window.ym)return;const u=[o.Params,t,n,i].filter(s);ym(e,...u)}}let a,c,u=function(e){return e.Development="development",e.Testing="testing",e.Preprod="preprod",e.Production="production",e}({});function l(){return u.Production}function d(e){const t=l();return`${e}${t!==u.Production?t[0]:""}`}const h=()=>{const e=l();try{const t=i.getEcomSettings()?.length;if(!a||t!==c){c=t;const r=i.getCounterIdsWithEcomSettings()?.map((t=>{const r=e===u.Testing&&t.settings.isTesting,s=e===u.Production&&t.settings.isProduction;return r||s||[u.Development,u.Preprod].includes(e)?{...t,settings:{...t.settings,isAIFeatureEnabled:!r&&t.settings.isAIFeatureEnabled}}:void 0})).filter(s);if(r?.length){const e={};r.forEach((t=>{e[t.counterId]||(e[t.counterId]=t)})),a=Array.from(Object.values(e))}else{const t=i.getCounters().map((t=>({counterId:t.id,settings:{isProduction:e===u.Production,isTesting:e===u.Testing,isAIFeatureEnabled:!1}})));t.length&&(a=t)}}return a}catch{}};let p=function(e){return e.Observer="Observer",e.Factor="Factor",e.Revenue="Revenue",e.Global="Global",e.EventsBus="EventsBus",e.Storage="Storage",e.Mutex="Mutex",e.EventSendingState="EventSendingState",e.Markup="Markup",e.Feature="Feature",e}({});class m{static mapEcomEventToTransportFormat(e,t=!0){return{[e.eventKind]:e.data.reduce(((r,{factorId:s,revenue:n,internalData:o})=>(r[s]={id:e.eventId,revenue:n,...t&&o?Object.entries(o).reduce(((e,[t,r])=>(e[t]=r?.slice(0,Math.min(r.length,200)),e)),{}):void 0},r)),{})}}}const g=e=>{let t;return t="string"!=typeof e?JSON.stringify(e,void 0,2):e,t=t.replace(/&/g,"&").replace(//g,">"),t.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,(function(e){let t="";return/^"/.test(e)?/:$/.test(e):/true|false/.test(e)?t="true"===e?"":"":/null/.test(e),`${t}${e}`}))};class v extends m{sendEventToMarkup(e){console.log(g(e))}log(e,...t){console.log(e,...t)}async sendEcomEvent(e,t){console.log(g({...e,counterId:t}))}sendError(e,t,r,s){console.error({error:e,scope:t,context:r,counterId:s})}}let f=function(e){return e.CheckConversion="check_conversion",e}({});class y extends m{sendEventToMarkup(e){(async()=>{try{await fetch("https://mc.yandex.ru/ee",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{kind:f.CheckConversion,event:e}})})}catch(e){k(e,p.Markup,"fetch")}})()}sendEcomEvent(e,t){return i.visitParamsAsync(t,{__ym:{[d("ec2")]:e}})}log(e,...t){}sendError(e,t,r,s){try{let n;const o=Array.isArray(r)?r:[r];n=e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:{name:"Unknown error",message:String(e)};try{i.visitParams(s,{__ym:{[d("ec")]:{error:{...n,scope:t,context:o}}}})}catch{}}catch{}}}let w;function b(){const e=l();try{return w||(w=e===u.Development?new v:new y),w}catch{}}function k(e,t,r){const s=b(),n=h();if(n?.length&&s)try{n.forEach((n=>{s.sendError(e,t,r,n.counterId)}))}catch{}}let E=function(e){return e.Ping="Ping",e.AIFeature="AIFeature",e}({});const S=[{feature:E.Ping,samplingRate:100},{feature:E.AIFeature,counterFlag:"isAIFeatureEnabled"}];class C{constructor(){r(this,"maxAttempts",5),r(this,"retryInterval",500),r(this,"featuresState",{}),r(this,"initPromise",null)}initUserFeatures(){this.initPromise=(async()=>{try{const e=await this.waitForCounters();e?.length&&await this.init(e)}catch(e){k(e,p.Feature,"INIT_USER_FEATURES")}})()}hasFeature(e){return this.featuresState[e]??!1}async hasFeatureWithWaitInit(e){try{return await this.initPromise,this.hasFeature(e)}catch{}return!1}getFeatureRand(e,t){return e.split("").reduce(((e,t)=>e+t.charCodeAt(0)),0)%t}getSampleRateValueFromClientId(e,t){const r=String(t);return Number(e.slice(-r.length))}async waitForCounters(e=0){const t=h();return t?.length?t:esetTimeout(e,this.retryInterval))),this.waitForCounters(e+1)):t}async init(e){const t=await i.getClientId(e[0].counterId);this.featuresState=S.reduce(((r,{feature:s,samplingRate:n,counterFlag:o})=>{let i=!0;if(n){const e=void 0!==t?this.getSampleRateValueFromClientId(t,n):void 0;i=void 0!==e&&e%n===this.getFeatureRand(s,n)}const a=!o||e.some((e=>e.settings[o]));return r[s]=i&&a,r}),{})}}let P;function x(){try{return P||(P=new C),P}catch(e){k(e,p.Feature,"GET_FEATURE_MANAGER")}}const T="ecom-event";class I{constructor(e){this.target=e}on(e,t){this.target.addEventListener(T,(r=>{try{e.includes(r.detail.eventKind)&&t(r.detail)}catch(e){k(e,p.EventsBus,[T,"ON_EVENT"])}}))}emit(e){try{this.target.dispatchEvent(new CustomEvent(T,{detail:e}))}catch(t){k(t,p.EventsBus,["EMIT",e.observerId,e.eventKind])}}}let L;function _(){try{L||(L=new I(new EventTarget))}catch(e){k(e,p.EventsBus,"CREATE_EVENTS_BUS")}return L}let N,R=function(e){return e.TYPEnabled="ea84",e.SendingEvents="eq31",e.TestKey="ew43",e.Ping="ps78",e}({});class A{get(e){try{return window.localStorage.getItem(e)}catch(e){k(e,p.Storage,"GET_KEY")}return null}set(e,t){try{window.localStorage.setItem(e,t)}catch(e){k(e,p.Storage,"SET_KEY")}}remove(e){try{window.localStorage.removeItem(e)}catch(e){k(e,p.Storage,"REMOVE_KEY")}}}let M=0;const F=5;function O(){try{if(!N&&Mn&&this.isEventState(n)?(n.counterId===e&&n.event.eventId===t.eventId&&(r=n),s.push(n),s):s),[]);const n=this.getEventSendingKey(e,t.eventId);if(this.inProgressEvents[n])throw new Error("Event has already been sending");return r?(r.attemptNum++,r.sendStarted=Date.now()):(r={counterId:e,event:t,attemptNum:1,sendStarted:Date.now()},s.length<5&&s.push(r)),this.inProgressEvents[n]=!0,this.storage.set(this.stateKey,JSON.stringify(s)),r}completeSending(e,t){const r=this.getSendingState().filter((r=>r&&this.isEventState(r)&&!(r.counterId===e&&r.event.eventId===t)));delete this.inProgressEvents[this.getEventSendingKey(e,t)],this.storage.set(this.stateKey,JSON.stringify(r))}getEventSendingState(e,t){return this.getSendingState().find((r=>r&&this.isEventState(r)&&r.counterId===e&&r.event.eventId===t))}getReadyToRetransmitEvents(){const e=this.getSendingState();if(!e.length)return[];const t=Date.now(),r=e.filter((e=>{const r=t-e.event.created;return e&&this.isEventState(e)&&r<432e5&&e.attemptNum<3}));return this.storage.set(this.stateKey,JSON.stringify(r)),r.filter((e=>!this.inProgressEvents[this.getEventSendingKey(e.counterId,e.event.eventId)]))}getEventSendingKey(e,t){return`${e}-${t}`}getSendingState(){const e=this.storage.get(this.stateKey);if(!e)return[];let t;try{t=JSON.parse(e)}catch(e){k(e,p.EventSendingState,"GET_SENDING_STATE")}return this.isState(t)?t:[]}isState(e){return Array.isArray(e)}isEventState(e){return!!("object"==typeof e&&e&&"counterId"in e&&e.counterId&&"event"in e&&"object"==typeof e.event&&e.event)}}let D;let K=function(e){return e.CreateOrderClick="create_order_click",e.CreateOrderClickCapture="create_order_click_capture",e.OrderThankYouPage="order_thank_you_page",e.CreateLead="create_lead",e.BookService="book_service",e.Purchase="purchase",e.BeginCheckout="begin_checkout",e.Ping="ping",e}({});class j{constructor(e){this.collectors=e,r(this,"id",void 0),r(this,"transport",void 0),r(this,"sendingStateManager",void 0),this.transport=b(),this.sendingStateManager=function(){if(!D){const e=O();e&&(D=new B(e))}return D}()}stop(){}processEvent(e){try{Object.entries(this.collectors).forEach((([t,r])=>{const n=r.map((({factor:t,revenue:r})=>{const s=this.applyCollector(e,t);if(!s)return;const n="boolean"==typeof s.res?{isMatched:s.res}:s.res;if(!n.isMatched)return;const o={factorId:t.id,revenue:n.revenue,meta:n.meta,internalData:{...n.internalData,factorPerf:s.perf.toFixed(2).toString(),observer:this.id}};if(void 0!==o.revenue||!r)return o;const i=this.applyCollector(e,r);if(!i?.res)return o;const a="object"==typeof i.res?i.res:{revenue:i.res};return{...o,revenue:a.revenue,internalData:{...o.internalData,...a.internalData,revPerf:i.perf.toFixed(2).toString()}}})).filter(s);if(!n.length)return;const o=Date.now(),i={eventKind:t,observerId:this.id,created:o,eventId:this.createEventId(),data:n};_()?.emit(i);const a=this.getCounters();a?.length?((async()=>{try{await this.sendEcomEvent(i,a)}catch{}})(),this.sendEventToMarkup(i,a)):k("Counters list is empty",p.Observer,[this.id,"PROCESS_EVENT"])}))}catch(e){k(e,p.Observer,[this.id,"PROCESS_EVENT"])}}sendEventToMarkup(e,t){const r=function(e,t){const r=x()?.hasFeature(E.AIFeature);if(e.eventKind!==K.CreateOrderClickCapture||!r)return;const s=e.data.filter((e=>"universal-conversion-collector"===e.factorId))?.[0];return s?.meta?{eventId:e.eventId,countersIds:t,page:{title:window?.document?.title,url:window.location.href},internalData:s.internalData,...s.meta}:void 0}(e,t);r&&this.transport?.sendEventToMarkup(r)}createEventId(){return`${Date.now()}-${Math.floor(1e6*Math.random())}`}async sendEcomEvent(e,t){const r=this.transport;r&&await Promise.all(t.map((t=>(async()=>{try{this.sendingStateManager?.startSending(t,e),await r.sendEcomEvent(m.mapEcomEventToTransportFormat(e),t),this.sendingStateManager?.completeSending(t,e.eventId)}catch(e){k(e,p.Observer,"SEND_ECOM_EVENT")}})())))}getCounters(){return h()?.map((e=>e.counterId))}applyCollector(e,t){try{const r=performance.now();return{res:t.apply(e),perf:performance.now()-r}}catch(e){k(e,t.scope,[this.id,t.id])}}}class $ extends j{constructor(...e){super(...e),r(this,"id","retransmit-observer"),r(this,"interval",void 0)}start(){this.interval=setInterval((()=>{this.checkPageReady()}),500),setTimeout((()=>{this.stop()}),1e4),this.checkPageReady()}stop(){this.interval&&(clearInterval(this.interval),this.interval=void 0)}processEvent(){const e=this.sendingStateManager;e&&(async()=>{try{const t=e.getReadyToRetransmitEvents();for(const{event:e,counterId:r,attemptNum:s}of t)e.data=e.data.map((e=>({...e,internalData:{...e.internalData,attempt:(s+1).toString()}}))),await this.sendEcomEvent(e,[r])}catch(e){k(e,p.Observer,"RETRANSMIT")}})()}checkPageReady(){try{document.body&&i.isCounterReady()&&(this.processEvent(),this.stop())}catch(e){k(e,p.Observer,"RETRANSMIT")}}}function Y(e,{additions:t,allAdditionsRequired:r}){return r?t.every((t=>U(e,{keywords:[t]}))):!!U(e,{keywords:t})}function G(e,{match:t,index:r},{before:s,after:n,inMatched:o,contextLength:i}){if(o&&U(t,{keywords:o}))return!0;if(s){const t=i?Math.max(r-i,0):0;if(U(e.slice(t,r).trim(),{keywords:s}))return!0}if(n){if(U(e.slice(r+t.length,i?i+r+t.length:void 0).trim(),{keywords:n}))return!0}return!1}function U(e,t){const r=function(e,t,r=!1){const s=[],n=e.toLowerCase().trim();for(const e of t.keywords){const o="object"==typeof e&&!(e instanceof RegExp),i=o?e.keyword:e,a=r=>!(t.stopPhrases&&G(n,r,t.stopPhrases))&&(!o||Y(n,e));if(i instanceof RegExp)for(const e of n.matchAll(i)){const t={match:e[0].trim(),index:e.index};if(a(t)&&(s.push(t),!r))break}else{const e=n.indexOf(i);if(-1!==e){const t={match:i,index:e};a(t)&&s.push(t)}}if(s.length>=1&&!r)break}return s.length?s.map((e=>({phrase:e.match,phraseContext:n.length<100?n:n.slice(e.index,e.index+100).trim()}))):void 0}(e,t);return r?r[0]:void 0}const V=/matrix\((?:\d+,\s*){4}(-?\d+),\s*(-?\d+)\s*\)/;class W{constructor(){r(this,"id",void 0),r(this,"scope",void 0),r(this,"findElementsByPatterns",((e,t=1e4,r=document.body)=>{const s=[],n=[],o=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:r=>{try{const n=r.nodeValue?.toLowerCase().trim();if(!n||n.length>t)return NodeFilter.FILTER_SKIP;const o=U(n,e);if(o)return s.push(o),NodeFilter.FILTER_ACCEPT}catch(e){this.sendError(e,["TREE_WALKER"])}return NodeFilter.FILTER_SKIP}});for(;o.nextNode();){const e=o.currentNode.parentElement,t=s.shift();e&&"SCRIPT"!==e.tagName&&t&&n.push({node:e,match:t})}return n}))}static getNodeAttrsAndText(e){let t=e.innerText?.trim()?.toLowerCase();return t||(t=e?.getAttribute("value")?.trim()?.toLowerCase()??""),t=t.replace(W.numbersInBtn,"").replace(/\s{2,}/g," ").trim(),{convBtnCls:e.className,convBtnId:e.id,convBtnText:t}}log(e,...t){b()?.log(e,...t)}sendError(e,t){k(e,this.scope,t)}collectAttrs(e,t=5){let r=1,s=e;const n={ids:[],classNames:[]};for(;s&&r<=t;)n.ids.push(s.id),n.classNames.push(s.className),s=s.parentElement,r++;return n}checkVisibility(e,t=void 0,r=13){let s=1,n=e;const o={display:"none",visibility:"hidden",opacity:0,...t};for(;s"number"==typeof r?parseFloat(e?.[t])===r:e?.[t]===r)))return!1;if("fixed"===e.position){if("-"===e.left?.[0]||"-"===e.right?.[0])return!1;const t=e.right?.match(/(\d+)%?/),r=t?.[1]?parseInt(t[1],10):0,s="%"===e.right?.[e.right?.length-1];if(r>=100&&s||r>=1e3)return!1;const n=e.transform?.match(V),o=n?.[1]?parseInt(n[1],10):0,i=n?.[2]?parseInt(n[2],10):0;if(o<0||i<0)return!1}s++,n=n.parentElement}return!0}}r(W,"numbersInBtn",/\d[\d\s.,]*(?!\s*клик)/g);class H extends W{constructor(...e){super(...e),r(this,"scope",p.Factor),r(this,"convCount",0),r(this,"lastMatchTimestamp",void 0)}apply(e){if(this.convCount&&this.lastMatchTimestamp){const e=Date.now()-this.lastMatchTimestamp;if(e>6e4)this.convCount=0;else if(e<1e3||this.convCount>10)return{isMatched:!1}}const t=this.applyFactor(e),r="boolean"==typeof t?{isMatched:t}:t;return r.isMatched&&(this.convCount++,this.lastMatchTimestamp=Date.now()),r}getParentHierarchy(e,t=4){const r=[];let s=e;for(let e=0;et?s?.slice(0,t):s}getConvMeta(e){try{const{convBtnCls:t,convBtnId:r,convBtnText:s}=H.getNodeAttrsAndText(e),n=this.getParentHierarchy(e),o=this.getCustomAttrs(e),i={convButton:{text:s,tag:e.tagName.toLowerCase()},hierarchy:n.map((e=>this.serializeElement(e))),parentText:this.getParentText(n)};return t&&(i.convButton.cls=t),r&&(i.convButton.id=r),o&&Object.keys(o).length>0&&(i.convButton.attrs=o),i}catch(e){k(e,p.Factor,[this.id,"ECOM_EVENT_META"])}}}class J extends H{constructor(e){super(),this.selectors=e}applyFactor(e){const t=e.target;if(t instanceof HTMLElement){const e=this.selectors.flatMap((e=>[e,`${e} *`])).some((e=>t.matches(e)));return{isMatched:e,internalData:e?H.getNodeAttrsAndText(t):void 0}}return!1}}class z extends J{constructor(){super(["#bx-soa-orderSave a",".btn-order-save"]),r(this,"id","1c-bitrix-click")}}class q extends W{constructor(...e){super(...e),r(this,"scope",p.Revenue)}parsePrice(e){if(!e.length)return;const t=e.map((e=>{const t=e.textContent?(e=>{if(!e)return;const t=e.match(/[\d.,\s]+/)?.[0]?.replace(/\s/g,"");if(!t)return;const r=t.includes(","),s=t.includes(".");if(r&&s)return t.lastIndexOf(",")>t.lastIndexOf(".")?parseFloat(t.replace(/\./g,"").replace(",",".")):parseFloat(t.replace(/,/g,""));return r?parseFloat(t.replace(",",".")):parseFloat(t)})(e.textContent):void 0;if(t)return{matchedNode:e,revenue:t}})).filter(s).sort(((e,t)=>e.revenue-t.revenue)),r=t[t.length-1];return t.length?{revenue:r.revenue,matchedNode:r.matchedNode,internalData:{"raw-revenue":e.map((e=>e.textContent?.slice(50))).filter(s).slice(0,2).join(",")}}:void 0}}class X extends q{constructor(e){super(),this.selectors=e}apply(){const e=this.selectors.flatMap((e=>[...document.querySelectorAll(e)])),t=this.parsePrice(e);return t?((e,t)=>{const r={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&!t.includes(s)&&(r[s]=e[s]);return r})({...t},["matchedNode"]):t}}class Z extends X{constructor(){super([".bx-soa-cart-total-line-total .bx-soa-cart-d"]),r(this,"id","1c-bitrix-click-parsed-revenue")}}class Q extends J{constructor(){super([".litecheckout__submit-btn",'[name="dispatch[checkout.place_order]"]',"#litecheckout_place_order"]),r(this,"id","cs-cart-click")}}class ee extends X{constructor(){super([".ty-checkout-summary__total-sum"]),r(this,"id","cs-cart-click-parsed-revenue")}}class te extends J{constructor(){super([".co-button--checkout","#create_order"]),r(this,"id","insales-click")}}class re extends X{constructor(){super([".co-basket_total-price"]),r(this,"id","insales-click-parsed-revenue")}}class se extends J{constructor(){super(['[name="finish_registration"]','[value="Подтвердить заказ"]',".nevigen-onestepcheckout-finish button",".button_order_finish","#button_order_finish","#cart-button-finish"]),r(this,"id","joomla-click")}}class ne extends X{constructor(){super([".jshop_subtotal .total .value","#total_cart .total .value",".totalvalue"]),r(this,"id","joomla-click-parsed-revenue")}}class oe extends J{constructor(){super([".shop2-btn"]),r(this,"id","megagroup-click")}}class ie extends X{constructor(){super([".cart-total__item.last_item .cart-total__body"]),r(this,"id","megagroup-click-parsed-revenue")}}class ae extends J{constructor(){super(["#simplecheckout_button_confirm",'[data-onclick="createOrder"]',"#button-confirm","#confirm_checkout","#button_checkout","#button-go"]),r(this,"id","opencart-click")}}class ce extends X{constructor(){super(["#total_total .simplecheckout-cart-total-value","#unicheckout .total","#total_total"]),r(this,"id","opencart-parsed-revenue-selector-data-collector")}}class ue extends J{constructor(){super(['[class*="cartpage-form"] .t-submit','[class*="orderform"] .t-submit']),r(this,"id","tilda-click")}}const le=['[class*="cartwin-totalamount-content"] [class*="cartwin-prodamount-price"]'];class de extends X{constructor(){super(le),r(this,"id","tilda-parsed-revenue-selector-data-collector")}}class he extends H{constructor(...e){super(...e),r(this,"buttonSelector",'[class*="btn"], [class*="submit"], [class*="button"], [class*="confirm"], [id*="btn"], [id*="submit"], [id*="button"], [id*="confirm"], a, button, [type="submit"], [name="submit"]'),r(this,"containerClasses",["buttons","btns"]),r(this,"buttonKeywords",["btn","submit","button","confirm"]),r(this,"innerButtonBlockPattern",{keywords:[H.numbersInBtn,"загрузка","loading"]}),r(this,"contentPatterns",void 0)}applyFactor(e){if(!(e.target instanceof HTMLElement))return!1;let t=e.target,r=!1;for(let e=1;e<=2&&t;e++)if(t=t.closest(this.buttonSelector),t&&!this.isContainer(t)){if(r=this.checkContent(t),r)break;t=t.parentElement}if(!r||!t)return!1;return{isMatched:r,meta:this.getConvMeta(t),internalData:{...H.getNodeAttrsAndText(t),v:"5"}}}checkContent(e){const t=e?.innerText?.trim()?.toLowerCase(),r=e?.getAttribute("value")?.trim()?.toLowerCase();let s;return t&&t.length<=50&&(s=U(t,this.contentPatterns)),!s&&r&&(s=U(r,this.contentPatterns)),!!s}isButton(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName?.toLowerCase();return"a"===t||"button"===t||(!(!e.getAttribute("onclick")&&"submit"!==e.getAttribute("type")&&"submit"!==e.getAttribute("name"))||!!U(`${e.className} ${e.id}`,{keywords:this.buttonKeywords}))}isContainer(e){if(!(e instanceof HTMLElement))return!1;if(["a","button","input"].includes(e.tagName.toLowerCase()))return!1;if((e.className||e.id)&&U(`${e.className} ${e.id}`,{keywords:this.containerClasses}))return!0;let t=0;const r=this.checkVisibility(e),s=new Set;for(let n=0;n1))return!0}return!1}findInnerButtons(e,t,r=1){if(this.isButton(e)){const r=e.innerText?.replace(/[()[\]{}.,:;!?₽$€]/g,"")?.trim();return!r||t&&!this.checkVisibility(e)||U(r,this.innerButtonBlockPattern)?[]:[r]}if(r>2)return[];const s=[];for(let n=0;n{let t;const r=[];for(;null!==(t=this.revenueRegExp.exec(e));){const s=e.substring(0,t.index);if(this.blackList.some((e=>e.test(s.toLowerCase().trim())))){this.log("BLACKLIST MATCHED",s.toLowerCase().trim());continue}const n=Number.parseFloat(t[1].replace(/[.,\s]/g,""));n>=99&&n<=999999&&r.push(n)}return r}))}apply(e){const t=[];for(const e of this.findElementsByPatterns({keywords:this.keywords},50)){this.findRevenue(e.node).items.length&&t.push(this.findRevenue(e.node))}let r=this.getRelevantValue(t);if(r)return this.log("HIGH PRIORITY VERDICT",r),r;for(const e of this.findElementsByPatterns({keywords:this.lowPriorityKeywords},50)){this.findRevenue(e.node).items.length&&t.push(this.findRevenue(e.node))}return t.length&&this.log("low priority results",t),t&&0!==t.length&&(r=this.getRelevantValue(t,!0)),r&&this.log("LOW PRIORITY VERDICT",r),r}getRelevantValue(e,t=!1){let r=e.filter((e=>e.isSelectorMatched&&1===e.items.length));return r.length?Math.min(...r.flatMap((e=>e.items))):t?(r=e.filter((e=>e.items.length)).sort(((e,t)=>{const r=e.items.length-t.items.length;return 0===r?e.isSelectorMatched?1:-1:r})),r[0]?.items.length?Math.min(...r[0].items):void 0):void 0}findRevenue(e){let t=[],r=e,s=0,n=!0,o=!1;for(;r&&!t.length&&s<5;){const e=window.getComputedStyle(r);if("none"===e.display||"line-through"===e.textDecoration)break;const i=r.textContent?.toLowerCase().trim()||"";if(i.length>350){this.log("MAX TEXT LENGTH EXCEEDED",i);break}if(i.length&&(t=this.parseRevenue(i)),t.length){this.log("RESULT NODE",r);break}let a;o?a=r.parentElement?.closest(this.selector):(a=r.nextElementSibling,o=!0),a||(n=!1,a=r.parentElement),r=a,s++}return{items:t,isSelectorMatched:n}}}class Ce extends J{constructor(){super([".js-submit-order-button"]),r(this,"id","webasyst-click")}}class Pe extends X{constructor(){super([".wa-item-total .wa-price"]),r(this,"id","webasyst-click-parsed-revenue")}}class xe extends J{constructor(){super([".wc-block-components-checkout-place-order-button",'[name="woocommerce_checkout_place_order"]',"#place_order"]),r(this,"id","woocommerce-click-selector-factor-collector")}}class Te extends X{constructor(){super([".wc-block-components-totals-item__value",".order-total .woocommerce-Price-amount"]),r(this,"id","woocommerce-parsed-revenue-selector-data-collector")}}class Ie extends j{constructor(...e){super(...e),r(this,"id","base-click-observer"),r(this,"clickCb",void 0),r(this,"capture",!1)}start(){this.clickCb=e=>{this.processEvent(e)},window.document.addEventListener("click",this.clickCb,{capture:this.capture})}stop(){this.clickCb&&window.document.removeEventListener("click",this.clickCb,{capture:this.capture})}}class Le extends Ie{constructor(...e){super(...e),r(this,"id","capture-click-observer"),r(this,"capture",!0)}}function _e(e,t=!1){return e.map((([e,r])=>({factor:e,revenue:r,isZeroCodeCollector:t})))}function Ne(){return[[new pe,new Se]]}function Re(e){return{[e]:[..._e([[new z,new Z],[new Q,new ee],[new te,new re],[new se,new ne],[new oe,new ie],[new ae,new ce],[new ue,new de],[new Ce,new Pe],[new xe,new Te],[new ke,new Se]])]}}class Ae extends H{isGa4Event(e){return"object"==typeof e&&!!e&&"event"in e&&"ecommerce"in e}}class Me extends Ae{constructor(...e){super(...e),r(this,"id","ga4-data-layer-begin-checkout")}static isGa4BeginCheckoutData(e){return!!e&&"object"==typeof e&&"value"in e&&!!e.value&&("string"==typeof e.value||"number"==typeof e.value)}applyFactor(e){if(!this.isGa4Event(e)||"begin_checkout"!==e.event)return!1;let t;return this.log("event ga4",JSON.stringify(e,null,4)),Me.isGa4BeginCheckoutData(e.ecommerce)&&(t=Number(e.ecommerce.value)),{isMatched:!0,revenue:t}}}class Fe extends Ae{constructor(...e){super(...e),r(this,"id","ga4-data-layer-purchase")}static isGa4PurchaseData(e){return!!e&&"object"==typeof e&&"value"in e&&"currency"in e&&("string"==typeof e.value||"number"==typeof e.value)&&"string"==typeof e.currency}applyFactor(e){if(!this.isGa4Event(e)||"purchase"!==e.event)return!1;let t;return Fe.isGa4PurchaseData(e.ecommerce)&&(t=Number(e.ecommerce.value)),{isMatched:!0,revenue:t}}}class Oe extends H{isGTagEvent(e){return t=e,"[object Arguments]"===Object.prototype.toString.call(t)&&3===e.length&&"event"===e[0]&&"object"==typeof e[2]&&!!e[2];var t}}class Be extends Oe{constructor(...e){super(...e),r(this,"id","gtag-data-layer-begin-checkout")}applyFactor(e){if(!this.isGTagEvent(e)||"begin_checkout"!==e?.[1])return!1;let t;return this.log("event gtag begin_checkout",JSON.stringify(e,null,4)),Me.isGa4BeginCheckoutData(e[2])&&(t=Number(e[2].value)),{isMatched:!0,revenue:t}}}class De extends Oe{constructor(...e){super(...e),r(this,"id","gtag-data-layer-purchase")}applyFactor(e){if(!this.isGTagEvent(e)||"purchase"!==e?.[1])return!1;let t;return this.log("event gtag purchase",JSON.stringify(e,null,4)),Fe.isGa4PurchaseData(e[2])&&(t=Number(e[2].value)),{isMatched:!0,revenue:t}}}class Ke extends H{isUaEvent(e){return"object"==typeof e&&!!e&&"ecommerce"in e&&!!e.ecommerce&&"object"==typeof e.ecommerce&&("purchase"in e.ecommerce||"checkout"in e.ecommerce)}}class je extends Ke{constructor(...e){super(...e),r(this,"id","ua-data-layer-begin-checkout")}getRevenue(e){return e.ecommerce.checkout?.products?.reduce(((e,t)=>{const r=t.quantity??1,s=t.price??0,n="number"==typeof r||"string"==typeof r?Number(r):void 0,o="number"==typeof s||"string"==typeof s?Number(s):void 0;return void 0===n||void 0===o||Number.isNaN(n)||Number.isNaN(o)?e:e+n*o}),0)}applyFactor(e){if(!this.isUaEvent(e)||!e.ecommerce.checkout)return!1;this.log("event ua",JSON.stringify(e.ecommerce,null,4));const t=this.getRevenue(e);return{isMatched:!0,revenue:0!==t?t:void 0}}}class $e extends Ke{constructor(...e){super(...e),r(this,"id","ua-data-layer-purchase")}applyFactor(e){if(!this.isUaEvent(e)||!e.ecommerce.purchase)return!1;const t=e.ecommerce.purchase.actionField?.revenue;return{isMatched:!0,revenue:void 0===t?void 0:Number(t)}}}class Ye extends j{constructor(...e){super(...e),r(this,"id","data-layer-observer"),r(this,"origPushByFieldName",{})}start(){if("dataLayer"in window&&Array.isArray(window.dataLayer)){this.origPushByFieldName.dataLayer=window.dataLayer.push.bind(window.dataLayer);try{for(let e=0;e{const r=window;e in r&&Array.isArray(r[e])&&(r[e].push=(...e)=>{try{e.forEach((e=>this.processEvent(e)))}catch(e){k(e,p.Observer,"DATA_LAYER")}try{return t(...e)}catch(e){throw k(e,p.Observer,["ORIG_PUSH","DATA_LAYER"]),e}})}))}stop(){Object.entries(this.origPushByFieldName).forEach((([e,t])=>{const r=window;e in r&&Array.isArray(r[e])&&(r[e].push=t)}))}}class Ge extends H{parseEvent(e){if("https://ru-ibe.tlintegration.ru"!==e?.origin||!e?.data||"string"!=typeof e.data)return;const t=e.data.match(/\{.*}/)?.[0];if(!t)return;const{data:r}=JSON.parse(t);return"object"==typeof r&&"_method"in r?{method:r._method,action:r.action,event:r._event,revenue:"number"==typeof r.amount?r.amount:void 0,target:r.target}:void 0}}class Ue extends Ge{constructor(...e){super(...e),r(this,"id","universal-tl-collector"),r(this,"revenue",void 0)}applyFactor(e){const t=this.parseEvent(e);return!!t?.action&&("change-order-price"===t.action&&t.revenue?(this.revenue=t.revenue,!1):"click"===t.action&&"payment-pay-button"===t.target&&{isMatched:!0,revenue:this.revenue})}}class Ve extends Ge{constructor(...e){super(...e),r(this,"id","universal-tl-typ-collector")}applyFactor(e){const t=this.parseEvent(e);return"bookingSuccess"===t?.event}}class We extends H{constructor(...e){super(...e),r(this,"id","universal-uhotels-collector"),r(this,"revenue",void 0)}applyFactor(e){if("https://api.uhotels.app"!==e.origin||!e?.data||!n(e.data))return!1;const t=e.data;return n(t.data)&&"priceNf"in t.data&&"number"==typeof t.data.priceNf&&(this.revenue=t.data.priceNf),"save-booking"===t.event&&{isMatched:!0,revenue:this.revenue}}}class He extends j{constructor(...e){super(...e),r(this,"id","message-observer"),r(this,"onMessageCb",void 0)}start(){this.onMessageCb=e=>{this.processEvent(e)},window.addEventListener("message",this.onMessageCb)}stop(){this.onMessageCb&&window.removeEventListener("message",this.onMessageCb)}}function Je(){return[[new Ue],[new We]]}const ze=/tilda|afisha/gu;class qe{constructor(e,t){this.storage=e,this.eventBus=t,r(this,"reset",void 0),t.on([K.CreateOrderClickCapture,K.BeginCheckout,K.OrderThankYouPage],this.onEcomEvent.bind(this))}isTypEnabled(){return!!ze.test(window.location.host)||"1"===this.storage.get(d(R.TYPEnabled))}onEcomEvent(e){const t=e.eventKind!==K.OrderThankYouPage;this.reset&&(clearTimeout(this.reset),this.reset=void 0),t?this.storage.set(d(R.TYPEnabled),"1"):this.reset=setTimeout((()=>{this.storage.set(d(R.TYPEnabled),"0")}),500)}}let Xe;class Ze extends H{constructor(){super(),r(this,"id","universal-thank-you-page-collector"),r(this,"titleKeywords",[/^(?:спасибо|благодарим|страница благодарности|благодарность)\p{P}*$/gu]),r(this,"commonKeywords",[/(?:заказ|бронь|обращение|заявка|покупка)(?:\s+\S+){0,3}\s+(?:создан|оформлен|принят|сформирован|размещен|получен|оплачен|отправлен|обработан|обрабатывается)[ао]?(?!\p{L})/gu,/(?!(!e.closest(this.typSelector)&&e.closest(this.feedbackSelector))&&this.checkVisibility(e))),e.length)return e.map((e=>({...e.match,...this.collectAttrs(e.node)})))}getRelUrl(){const e=window.location,t=new URLSearchParams([...new URLSearchParams(e.search).entries()].filter((([e])=>!e.toLowerCase().includes("utm")))).toString();return`${e.pathname}${t}${e.hash}`.toLowerCase()}}class Qe extends j{constructor(...e){super(...e),r(this,"id","page-hide-observer"),r(this,"callback",void 0)}start(){this.callback=()=>{document.body&&this.processEvent(void 0)},window.addEventListener("visibilitychange",this.callback)}stop(){this.callback&&window.removeEventListener("visibilitychange",this.callback)}}class et extends H{constructor(e){super(),this.views=e,r(this,"isPageReloaded",void 0),this.isPageReloaded=window.performance.navigation&&1===window.performance.navigation.type||window.performance.getEntriesByType("navigation").some((e=>"type"in e&&"reload"===e.type))}applyFactor(){return this.views.some((({url:e,referrer:t})=>{const r=!e||("string"==typeof e?document.location.href.includes(e):e.test(document.location.href)),s=this.isPageReloaded?"":document.referrer,n=!t||("string"==typeof t?s.includes(t):t.test(s));return r&&n}))}}class tt extends et{constructor(){super([{url:"/order/?ORDER_ID=",referrer:"/order/"}]),r(this,"id","1c-bitrix-page-view")}}class rt extends et{constructor(){super([{url:"index.php?dispatch=checkout.complete",referrer:"index.php?dispatch=checkout.checkout"}]),r(this,"id","cs-cart-page-view")}}class st extends et{constructor(){super([{url:"/orders/",referrer:/\/new_order$/}]),r(this,"id","insales-page-view")}}class nt extends X{constructor(){super([".co-price"]),r(this,"id","insales-page-view-parsed-revenue")}}class ot extends et{constructor(){super([{url:"checkout/finish",referrer:"checkout"},{url:"/finish",referrer:/\/step\d/}]),r(this,"id","joomla-page-view")}}class it extends et{constructor(){super([{url:"/index.php?route=checkout/success"},{url:"/order-success/"}]),r(this,"id","opencart-page-view")}}class at extends et{constructor(){super([{url:"/checkout/success",referrer:"/order"}]),r(this,"id","webasyst-page-view")}}class ct extends j{constructor(...e){super(...e),r(this,"id","page-view-observer"),r(this,"interval",void 0),r(this,"currentUrl",void 0)}start(){this.interval=setInterval((()=>{this.checkUrl()}),100),this.checkUrl()}stop(){this.interval&&clearInterval(this.interval)}checkUrl(){try{location.href!==this.currentUrl&&document.body&&(this.currentUrl=location.href,this.processEvent(void 0))}catch(e){k(e,p.Observer,"PAGE_VIEW_OBSERVER")}}}class ut extends j{constructor(){super({}),r(this,"id","ping-observer")}start(){document&&"loading"!==document.readyState?this.tryPing():document.addEventListener("DOMContentLoaded",(()=>this.tryPing()),{once:!0})}tryPing(){(async()=>{try{const e=O();if(!e)return;const t=d(R.Ping),r=Number(e.get(t));if(!await(x()?.hasFeatureWithWaitInit(E.Ping))||!isNaN(r)&&Date.now()-r<432e5)return;const s={eventKind:K.Ping,observerId:this.id,created:Date.now(),eventId:this.createEventId(),data:[{factorId:"ping-collector"}]},n=this.getCounters();n?.length&&(await this.sendEcomEvent(s,n),e.set(t,String(Date.now())))}catch{}})()}}const lt=b(),dt=x();try{lt?.log("START ECOM COLLECTOR"),dt?.initUserFeatures(),[new Ie({...Re(K.CreateOrderClick),[K.BookService]:_e(Ne())}),new Le({...Re(K.CreateOrderClickCapture),[K.CreateLead]:_e([[new Ee]]),[K.BookService]:_e(Ne())}),new ct({[K.OrderThankYouPage]:_e([[new st,new nt],[new it],[new ot],[new at],[new rt],[new tt],[new Ze]])}),new Qe({[K.OrderThankYouPage]:_e([[new Ze]])}),new He({[K.CreateOrderClickCapture]:_e(Je()),[K.CreateOrderClick]:_e(Je()),[K.OrderThankYouPage]:_e([[new Ve],[new We]])}),new Ye({[K.BeginCheckout]:_e([[new Me],[new je],[new Be]]),[K.Purchase]:_e([[new $e],[new Fe],[new De]])}),new ut,new $({})].forEach((e=>e.start()))}catch(e){k(e,p.Global,"INIT")}})();